<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml" id="teacherForm">
<head>
    <title>添加课程</title>
    <script type="text/javascript">
    var mainform;

    $(function (){
        mainform=$("#mainform");
        mainform.ligerForm();
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel, save);
        
        //调整form-bar
        $(".form-bar").css("width","560px");
    });
   
    function save() {
    	var courseIds = '';
    	$("input:checked").each(function (){
    		courseIds += $(this).val() + "," ;
    	});
    	
    	$("#courseIds").val( courseIds );
    	
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + data.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("clistList");
                   cancel();
                });
            }
        });
    }
    
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
 </script>
</head>

<body>
    <form name="mainform" method="post" id="mainform" action="${ctx}/qso/clist/course/save">
        <input type="hidden" name="cListId" value="${cListId}"/>
        <input type="hidden" id="courseIds" name="courseIds" />
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top: 10px; margin-left: 15px;">
       	<c:forEach items="${courses}" var="course" varStatus="status">
       		<c:if test="${0 eq (status.index % 4)}"><tr></c:if>
                <td align="left" class="l-table-edit-td" style="width:25%;"><input type="checkbox" name="courseId" value="${course.id}" ${cListId eq course.listId.id ? "checked" : ""} >${course.title}</input></td>
            <c:if test="${(0 ne status.index) and (3 eq (status.index % 4)) }"></tr></c:if>
            <c:if test="${status.last and (3 ne (status.index % 4))}"></tr></c:if>
       	</c:forEach>
		</table>		
    </form>
</body>
</html>
